const SequelizeDatabaseError = p => {
    let _s = Object.assign({
        data: {},
        changeCount: false,
        msg: '操作成功',
        code: 100
    }, p)
    if(typeof _s.data === 'string' && _s.data.indexOf('Error:') >= 0) {
        _s.msg = _s.data.split('\n    at ')[0] // \n4at1空格
        return {code: _s.code, data: null, msg: _s.msg}
    }else{
        if(_s.changeCount) {
            if(_s.data === 0 || _s.data[0] == 0) _s.msg = '操作失败，请稍后重试';
            _s.data = null;
        }
        return { code: 200, data:　_s.data, msg: _s.msg }
    }
}
const ResizeOSSImage = (url, style = 'w_100') => {
    return url + '?x-oss-process=image/resize,' + style
}

global.$utils = {
    _formmat_send_data: SequelizeDatabaseError,
    _resize: ResizeOSSImage
}
